package unq.uis.robots.servlets;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import unq.uis.robots.applicationsModels.ComprarRobotApplicationModel;
import unq.uis.robots.applicationsModels.JugadorVista;
import unq.uis.robots.applicationsModels.VenderRobotApplicationModel;
import unq.uis.robots.model.Jugador;
import unq.uis.robots.model.Robot;

@SuppressWarnings("serial")
public class VenderServlet extends HttpServlet {
	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {		
		long idRobot = Long.parseLong(request.getParameter("idRobot"));
		JugadorVista jugadorVista = (JugadorVista)request.getSession().getAttribute("vistaPrincipal");
		Robot robotAVender = jugadorVista.buscarRobotDelJugador(idRobot);
		
		
		VenderRobotApplicationModel venderRobotApplicationModel = new VenderRobotApplicationModel(jugadorVista, robotAVender);
		
		request.getSession().setAttribute("vender", venderRobotApplicationModel);
		request.getRequestDispatcher("vender.jsp").forward(request, response);		
	}	
	
}
